import { createSlice } from "@reduxjs/toolkit";
import dayjs from "dayjs";
export const CitySlice = createSlice({
  name: "CitySlice",
  initialState: {
    start: "北京",
    end: "广州",
    date: dayjs().format("YYYY-MM-DD"),
  },
  reducers: {
    ChangeSlice(state) {
      const temp = state.start;
      state.start = state.end;
      state.end = temp;
    },
    pode(state, { payload: { city, type } }) {
      state[type] = city;
    },
    day(state, { payload }) {
      state.date = payload.date;
    },
  },
});
// 每个 case reducer 函数会生成对应的 Action creators
export const { ChangeSlice, pode, day } = CitySlice.actions;

export default CitySlice.reducer;
